#include <iostream>
#include <fstream>
#include <io.h>
#include <time.h>
#include "ImageEvaluate.h"
#include "AnalisysImage.h"
#include "ImgQuaEv.h"
#include <vector>

int main(int argc, char* args[])
{

	if (argc == 2) {
		std::string imagePath = args[1];
		cv::Mat oriImage = cv::imread(imagePath, cv::IMREAD_ANYCOLOR | cv::IMREAD_ANYDEPTH);


		clock_t start = clock();
		//for (int i = 0; i < 10000; i++){
		//ImgEvaluate::midScore512(oriImage, imageParamss, 1);
		int R = oriImage.rows;
		int C = oriImage.cols;
		int startPosiY = R / 2;
		int startPosiX = C / 2;
		double midScore_old = 0.0, midScore_new = 0.0;
		double instensity_old = 0.0, intensity_new = 0.0;
		cv::Mat midImage_old = oriImage(cv::Rect(startPosiX, startPosiY, 512, 512)).clone();
		cv::Mat midImage_new = oriImage(cv::Rect(startPosiX, startPosiY, 512, 512)).clone();
		std::vector<bool> useFlag{false, false, false};
		bool overDensity = false;
		bool lessPoints = false;
		bool overExposure = false;
		int peaknum_old = ImageQuaEv::midScoreSelf(midImage_old, midScore_old, instensity_old);
		int peaknum_new = ImageQuaEv::midScoreSelfKK(midImage_new, midScore_new, intensity_new, overDensity, lessPoints, overExposure);


		std::cout << "=====================( Old Score )=====================" << std::endl;
		std::cout << "peaknum: " << peaknum_old << std::endl;
		std::cout << "midScore: " << midScore_old << std::endl;

		std::cout << "=====================( New Score )=====================" << std::endl;
		std::cout << "peaknum: " << peaknum_new << std::endl;
		std::cout << "midScore: " << midScore_new << std::endl;
		std::cout << "overDensity: " << overDensity << std::endl;
		std::cout << "lessPoints: " << lessPoints << std::endl;
		std::cout << "lessPoints: " << lessPoints << std::endl;




		clock_t end = clock();
		std::cout << (double)(end - start) / CLOCKS_PER_SEC << std::endl;















		//std::vector<std::vector<double>> scoreHeatMapVector;
		//std::vector<std::vector<double>> intensityHeatMapVector;
		//ImageQuaEv::ScoreHeatMapSelf(oriImage, scoreHeatMapVector, intensityHeatMapVector);
		//std::cout << imagePath << std::endl;
		//if (scoreHeatMapVector.size()) {
		//	for (size_t iy = 0; iy < scoreHeatMapVector.size(); ++iy) {
		//		for (size_t ix = 0; ix < scoreHeatMapVector[0].size(); ++ix) {
		//			std::cout << "  scoreHeatMapVector : " << iy << "," << ix << "," << scoreHeatMapVector[iy][ix] << std::endl;
		//		}
		//	}
		//}
	}
	return 0;
}
